﻿using System.Drawing;
using System.Windows.Forms;
using Business;
using System;
using System.IO;

namespace GogTasks.Entities
{
    /// <summary>
    /// An icon with three states
    /// </summary>
    public class NilzIcon
    {
        public static string FileExtension = ".png";
        public static string DisabledSuffix = "_d";
        public static string HighlightedSuffix = "_h";
        public static string StandardSuffix = "_s";

        private string _filename;
        Bitmap _imageStandard;
        Bitmap _imageDisabled;
        Bitmap _imageHighlighted;

        public Bitmap GetByControlState(Control control)
        {
            if (!control.Enabled) return _imageDisabled;
            return _imageStandard;
        }

        public Bitmap Highlighted
        {
            get { return _imageHighlighted; }
        }
        public Bitmap Disabled
        {
            get { return _imageDisabled; }
        }
        public Bitmap Standard
        {
            get { return _imageStandard; }
        }
        
        public NilzIcon(string filename)
        {
            _filename = filename;
        }

        public void LoadAll()
        {
            string appPath = Context.AppPath + Path.DirectorySeparatorChar;
            if (_filename.StartsWith(Path.DirectorySeparatorChar.ToString())) appPath = String.Empty;
            _imageStandard = new Bitmap(appPath + _filename + StandardSuffix + FileExtension);
            _imageDisabled = new Bitmap(appPath + _filename + DisabledSuffix + FileExtension);
            _imageHighlighted = new Bitmap(appPath +_filename + HighlightedSuffix + FileExtension);
        }
    }
}
